Skip to content

Conversation

@Sharashchandra
Copy link
Contributor

@Sharashchandra Sharashchandra commented Feb 28, 2025

This PR enhances the SnowflakeHook in the Airflow repo by completing the OAuth authentication flow. It adds logic to fetch the access token using the refresh_token, client_id, and client_secret, which are already managed in the extras of the Snowflake connection object.

Changes & Fixes:
Implements logic to exchange the refresh_token for a new access token before establishing a connection.
Resolves an issue where using refresh_token, client_id, and client_secret directly with SnowflakeHook results in the error:
main/newsfragments).

snowflake.connector.errors.DatabaseError: 250001 (08001): None: Failed to connect to DB: <account>.snowflakecomputing.com:443. Invalid OAuth access token.

Duplicate of #47073, Reopening because I messed up the updates

@boring-cyborg boring-cyborg bot added the provider:snowflake Issues related to Snowflake provider label Feb 28, 2025
@potiuk potiuk force-pushed the snowflake_hook_oauth branch from 2d0db9d to fe00766 Compare April 1, 2025 16:22
@potiuk
Copy link
Member

potiuk commented Apr 1, 2025

Rebased. This one looks good to merge if the questions are resolved @sunank200 ?

@potiuk
Copy link
Member

potiuk commented Apr 17, 2025

Needs to be rebased again. Can you please rebase? @Sharashchandra

@Sharashchandra
Copy link
Contributor Author

@potiuk rebased!

@bugraoz93 bugraoz93 force-pushed the snowflake_hook_oauth branch from cad0203 to 60d1f13 Compare April 18, 2025 21:41
@bugraoz93 bugraoz93 merged commit 6cf9d0b into apache:main Apr 18, 2025
2 checks passed
@boring-cyborg
Copy link

boring-cyborg bot commented Apr 18, 2025

Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions.

@bugraoz93
Copy link
Contributor

Congrats @Sharashchandra! 🎉

@gopidesupavan
Copy link
Member

gopidesupavan commented Apr 18, 2025

@Sharashchandra cant we merge get_oauth_token into single method ? this is being used in SnowflakeSqlApiHook and SnowflakeHook the only difference i could see here is self.account_identifier and conn_config['account'] ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

provider:snowflake Issues related to Snowflake provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants